<?php
session_start();
if(isset($_SESSION['userid'])&&$_SESSION['level']!=2)
{
	
	header ("location: login.php");
	exit();
}
?>
<?php
include("includes/top_user.php");
?>
<div id="wrapper">
	<div id="content">
		<div class="message_error" style="color:red"></div>
		<form id="fr_manage_thread" name="fr_manage_thread" action="act/save_page_content.php" method="post">
			<h3 style="text-decoration: underline;">Quản lý nội dung Bài Viết</h3><br>
			<h4>Bước 1 : Chọn trang cần thay đổi nội dung</h4><br>
			<select id="page" name="page" onchange="reloadContent(this);">
				<option value="">please choose page...</option>
				<option value="about_us">About us</option>
				<option value="career">Career</option>
<!--				<option value="contact_us">Contact us</option>-->
			</select>
			<br>
			<br>
			<h4>Bước 2 : Nội dung trang</h4> <br>
			<textarea class="ckeditor" id="page_content" name="page_content" rows="70" cols="30" ></textarea>
			<br>
			
		</form>
		=====================================<input style="width: 150px" type="button" id="save" name="save" value="Save" />=====================================
	</div><!--content-->
	<?php
	include("includes/sidebar.php");
	?>
</div><!--wrapper-->

<script type="text/javascript">
    function reloadContent(select_input){
	      if($(select_input).val() != ''){
		      $.ajax({
		        url : "act/reload_content.php",
		        type : "POST",
		        data : {data: $(select_input).val() },
		        dataType : "json",
		        success : function(obj){
		          var a = "";
		          if (obj[0]!=null) {
		              a=obj[0];
		          }
		            //console.log(obj.page_content);
		            CKEDITOR.instances.page_content.setData(a);
		          }
		      });
      }
    }
    $('#save').click(function(){
		if($('#page').val()!=''){
			$('#fr_manage_thread').submit();
		}else{
			alert('chọn trang trước đã!!!');
		}
    });
   
</script>
<?php
include("includes/footer.php");
?>
